import { Rule, RuleType } from "@midwayjs/validate";
import { IEquitiesData, WechatLoginType } from "../interfaces/IUser.interface";

/**用户状态 */
export enum UserStatus{
    NORMAL = 1,
    BANNED = 2,
}
/**会员等级 */
export enum UserLevel{
    /**普通用户 */
    Ordinary = 0,
    /**普通会员 */
    Primary = 1,
    /**中级会员 */
    Intermediate = 2,
    /**高级会员 */
    Senior = 3,
}
/**会员等级权益 */
export  function UserEquities(level:number){
    level = level == null?0:level;
    const equitiesList:IEquitiesData[] = [
        {
            ParticipateCount:0,
            QueryCount:0
        },
        {
            ParticipateCount:-1,
            QueryCount:-1
        }
    ]
    return equitiesList[level]; 
}


export class UserOaCodeDTO{
    @Rule(RuleType.required())
    url:string;
    @Rule(RuleType.any())
    scope:string;
}

export class UserLoginDTO{
    @Rule(RuleType.string().required().min(6).max(16))
    username:string;

    @Rule(RuleType.string().required().min(8).max(32))
    password:string;
}

export class UserWechatLoginDTO{
    @Rule(RuleType.string().required())
    code:string;

    @Rule(RuleType.string().required())
    /**微信登录类型： */
    type:WechatLoginType;
}

export class UserBindDTO{
    @Rule(RuleType.string().required())    
    username:string;
    @Rule(RuleType.string().required())
    phone:string;
}

export class UserPhoneCodeDTO{
    @Rule(RuleType.string().required().min(11).max(11))
    phone:string;
}
export class UserPhoneVerCodeDTO{
    @Rule(RuleType.string().required().min(11).max(11))
    phone:string;
    @Rule(RuleType.string().required().max(6).min(6))
    code:string;
}

export class UserRechargeDTO{
    @Rule(RuleType.required())
    price:number;
}